using System.Xml.Serialization;
using CodePlex.DnD4eCampaignManager.DnD4e;
using CodePlex.DnD4eCampaignManager.DnD4e.Interfaces;

namespace CodePlex.DnD4eCampaignManager.Repositories.XmlRepositories
{
    public class LocationXmlRepository : BaseXmlRepository<ILocation>, ILocationRepository
    {
        private static readonly XmlSerializer _xmlSerializer = new XmlSerializer(typeof ( Location ));

        public LocationXmlRepository()
        {
            InitializeRepository();
        }

        protected override string Extension
        {
            get { return ".location"; }
        }

        protected override string Folder
        {
            get { return "Locations"; }
        }

        protected override XmlSerializer XmlSerializer
        {
            get { return _xmlSerializer; }
        }

        public new void Save(ILocation domainObject)
        {
            if ( domainObject.Index.HasValue )
            {
                return;
            }
            base.Save(domainObject);
        }
    }
}